package com.spc.car.data.service.sys.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spc.car.data.domain.sys.vo.SysExternalAssistanceVO;
import com.spc.car.data.entity.sys.SysExternalAssistance;
import com.spc.car.data.mapper.sys.SysExternalAssistanceMapper;
import com.spc.car.data.service.sys.SysExternalAssistanceService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 申请外部协作人员 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-04-22
 */
@Service
public class SysExternalAssistanceServiceImpl extends ServiceImpl<SysExternalAssistanceMapper, SysExternalAssistance> implements SysExternalAssistanceService {

    @Override
    public Long saveToTable(SysExternalAssistance sysExternalAssistance) {
        baseMapper.insert(sysExternalAssistance);
        return sysExternalAssistance.getId();
    }

    @Override
    public boolean updataExternalAssistance(SysExternalAssistance sysExternalAssistance) {
        return updateById(sysExternalAssistance);
    }

    @Override
    public SysExternalAssistance getExternalAssistanceById(Long id) {
        return getById(id);
    }

    @Override
    public SysExternalAssistanceVO getOneExternalAssistance(Long id) {
        SysExternalAssistance sysExternalAssistance = getById(id);
        SysExternalAssistanceVO sysExternalAssistanceVO = new SysExternalAssistanceVO();
        BeanUtils.copyProperties(sysExternalAssistance, sysExternalAssistanceVO);
        return sysExternalAssistanceVO;
    }

    @Override
    public List<SysExternalAssistanceVO> getExternalAssistanceList(String userName) {
        return baseMapper.getExternalAssistanceList(userName);
    }

}
